#!/bin/sh

#Avoid PID-files, crons, or anything else that tries to evaluate 
# processes that aren't their children.
#There is a very good reason why in UNIX, you can ONLY wait on your 
# children. Any method (ps parsing, pgrep, storing a PID, ...) that 
# tries to work around that is flawed and has gaping holes in it. Just say no.
#Instead you need the process that monitors your process to be the 
# process' parent. What does this mean? It means only the process that 
# starts your process can reliably wait for it to end. In bash, this 
# is absolutely trivial.
:

until myserver; do
    echo "Server 'myserver' crashed with exit code $?.  Respawning.." >&2
    sleep 5h
done


